//@author A0105511Y
#include "UnitTestHistory.h"

//test for adding an add action
TEST_F(UnitTestHistory, HistoryTest_Add) {
	History myHistory;
	Task task2("Task 2", "11/11/2013" , "0900", "2000", "school");
	myHistory.addAction(Action(COMMAND_ADD,task2));

	Action newAction(myHistory.getLastAction());

	string expectedOutput = task2.toString();

	ASSERT_EQ(expectedOutput, newAction.getCurrentTask().toString());
}

//test for adding an modify action
TEST_F(UnitTestHistory, HistoryTest_Modify) {
	History myHistory;
	Task task1("Task 1", "11/11/2013", "0700", "1700", "untagged");
	Task task2("Task 2", "11/11/2013" , "0900", "2000", "school");
	myHistory.addAction(Action(COMMAND_MODIFY,task1,task2));

	Action newAction(myHistory.getLastAction());

	string expectedOutput = task1.toString() + task2.toString();

	ASSERT_EQ(expectedOutput, newAction.getCurrentTask().toString() + newAction.getPreviousTask().toString());
}

//test for undo an action
TEST_F(UnitTestHistory, HistoryTest_Undo) {
	History myHistory;
	Task task1("Task 1", "11/11/2013", "0700", "1700", "untagged");
	Task task2("Task 2", "11/11/2013" , "0900", "2000", "school");
	myHistory.addAction(Action(COMMAND_MODIFY,task1,task2));
	myHistory.addAction(Action(COMMAND_MODIFY,task2,task1));
	myHistory.undoAction();

	Action newAction(myHistory.getLastAction());

	string expectedOutput = task1.toString() + task2.toString();

	ASSERT_EQ(expectedOutput, newAction.getCurrentTask().toString() + newAction.getPreviousTask().toString());
}